<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--
 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
 * Copyright (C) 2003-2010 Frederico Caldeira Knabben
 *
 * == BEGIN LICENSE ==
 *
 * Licensed under the terms of any of the following licenses at your
 * choice:
 *
 *  - GNU General Public License Version 2 or later (the "GPL")
 *    http://www.gnu.org/licenses/gpl.html
 *
 *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
 *    http://www.gnu.org/licenses/lgpl.html
 *
 *  - Mozilla Public License Version 1.1 or later (the "MPL")
 *    http://www.mozilla.org/MPL/MPL-1.1.html
 *
 * == END LICENSE ==
-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>FCKDomRange - Tests for JsUnit</title>
	<script src="../../../editor/_source/fckscriptloader.js" type="text/javascript"></script>
	<script type="text/javascript" src="tests.js"></script>
	<script type="text/javascript" src="../_jsunit/app/jsUnitCore.js"></script>
	<script type="text/javascript">

var FCKConfig = { EnterMode : 'p' } ;

FCKScriptLoader.Load( 'FCKDomRange' ) ;

	</script>
	<script type="text/javascript">

function test_SetStart_1()
{
	var range = new FCKDomRange( window ) ;
	range.SetStart( document.getElementById('_Span'), 1 ) ;

	assertEquals( 'StartContainer', document.getElementById('_Span'), range.StartContainer ) ;
	assertEquals( 'StartBlock', document.getElementById('_P'), range.StartBlock ) ;
	assertEquals( 'StartBlockLimit', document.body, range.StartBlockLimit ) ;

	assertEquals( 'EndContainer', document.getElementById('_Span'), range.EndContainer ) ;
	assertEquals( 'EndBlock', document.getElementById('_P'), range.EndBlock ) ;
	assertEquals( 'EndBlockLimit', document.body, range.EndBlockLimit ) ;

	assertTrue( 'CheckIsCollapsed', range.CheckIsCollapsed() ) ;
}

function test_SetStart_2()
{
	var range = new FCKDomRange( window ) ;
	range.SetStart( document.getElementById('_Span'), 2 ) ;

	assertEquals( 'StartContainer', document.getElementById('_Span'), range.StartContainer ) ;
	assertEquals( 'StartBlock', document.getElementById('_P'), range.StartBlock ) ;
	assertEquals( 'StartBlockLimit', document.body, range.StartBlockLimit ) ;

	assertEquals( 'EndContainer', document.getElementById('_Span'), range.EndContainer ) ;
	assertEquals( 'EndBlock', document.getElementById('_P'), range.EndBlock ) ;
	assertEquals( 'EndBlockLimit', document.body, range.EndBlockLimit ) ;

	assertTrue( 'CheckIsCollapsed', range.CheckIsCollapsed() ) ;
}

function test_SetStart_3()
{
	var range = new FCKDomRange( window ) ;
	range.SetStart( document.getElementById('_Span'), 3 ) ;

	assertEquals( 'StartContainer', document.getElementById('_P'), range.StartContainer ) ;
	assertEquals( 'StartBlock', document.getElementById('_P'), range.StartBlock ) ;
	assertEquals( 'StartBlockLimit', document.body, range.StartBlockLimit ) ;

	assertEquals( 'EndContainer', document.getElementById('_P'), range.EndContainer ) ;
	assertEquals( 'EndBlock', document.getElementById('_P'), range.EndBlock ) ;
	assertEquals( 'EndBlockLimit', document.body, range.EndBlockLimit ) ;

	assertTrue( 'CheckIsCollapsed', range.CheckIsCollapsed() ) ;
}

function test_SetStart_4()
{
	var range = new FCKDomRange( window ) ;
	range.SetStart( document.getElementById('_Span'), 4 ) ;

	assertEquals( 'StartContainer', document.getElementById('_P'), range.StartContainer ) ;
	assertEquals( 'StartBlock', document.getElementById('_P'), range.StartBlock ) ;
	assertEquals( 'StartBlockLimit', document.body, range.StartBlockLimit ) ;

	assertEquals( 'EndContainer', document.getElementById('_P'), range.EndContainer ) ;
	assertEquals( 'EndBlock', document.getElementById('_P'), range.EndBlock ) ;
	assertEquals( 'EndBlockLimit', document.body, range.EndBlockLimit ) ;

	assertTrue( 'CheckIsCollapsed', range.CheckIsCollapsed() ) ;
}

function test_SetEnd_1()
{
	var range = new FCKDomRange( window ) ;
	range.SetEnd( document.getElementById('_Span'), 1 ) ;

	assertEquals( 'StartContainer', document.getElementById('_Span'), range.StartContainer ) ;
	assertEquals( 'StartBlock', document.getElementById('_P'), range.StartBlock ) ;
	assertEquals( 'StartBlockLimit', document.body, range.StartBlockLimit ) ;

	assertEquals( 'EndContainer', document.getElementById('_Span'), range.EndContainer ) ;
	assertEquals( 'EndBlock', document.getElementById('_P'), range.EndBlock ) ;
	assertEquals( 'EndBlockLimit', document.body, range.EndBlockLimit ) ;

	assertTrue( 'CheckIsCollapsed', range.CheckIsCollapsed() ) ;
}

function test_SetEnd_2()
{
	var range = new FCKDomRange( window ) ;
	range.SetEnd( document.getElementById('_Span'), 2 ) ;

	assertEquals( 'StartContainer', document.getElementById('_Span'), range.StartContainer ) ;
	assertEquals( 'StartBlock', document.getElementById('_P'), range.StartBlock ) ;
	assertEquals( 'StartBlockLimit', document.body, range.StartBlockLimit ) ;

	assertEquals( 'EndContainer', document.getElementById('_Span'), range.EndContainer ) ;
	assertEquals( 'EndBlock', document.getElementById('_P'), range.EndBlock ) ;
	assertEquals( 'EndBlockLimit', document.body, range.EndBlockLimit ) ;

	assertTrue( 'CheckIsCollapsed', range.CheckIsCollapsed() ) ;
}

function test_SetEnd_3()
{
	var range = new FCKDomRange( window ) ;
	range.SetEnd( document.getElementById('_Span'), 3 ) ;

	assertEquals( 'StartContainer', document.getElementById('_P'), range.StartContainer ) ;
	assertEquals( 'StartBlock', document.getElementById('_P'), range.StartBlock ) ;
	assertEquals( 'StartBlockLimit', document.body, range.StartBlockLimit ) ;

	assertEquals( 'EndContainer', document.getElementById('_P'), range.EndContainer ) ;
	assertEquals( 'EndBlock', document.getElementById('_P'), range.EndBlock ) ;
	assertEquals( 'EndBlockLimit', document.body, range.EndBlockLimit ) ;

	assertTrue( 'CheckIsCollapsed', range.CheckIsCollapsed() ) ;
}

function test_SetEnd_4()
{
	var range = new FCKDomRange( window ) ;
	range.SetEnd( document.getElementById('_Span'), 4 ) ;

	assertEquals( 'StartContainer', document.getElementById('_P'), range.StartContainer ) ;
	assertEquals( 'StartBlock', document.getElementById('_P'), range.StartBlock ) ;
	assertEquals( 'StartBlockLimit', document.body, range.StartBlockLimit ) ;

	assertEquals( 'EndContainer', document.getElementById('_P'), range.EndContainer ) ;
	assertEquals( 'EndBlock', document.getElementById('_P'), range.EndBlock ) ;
	assertEquals( 'EndBlockLimit', document.body, range.EndBlockLimit ) ;

	assertTrue( 'CheckIsCollapsed', range.CheckIsCollapsed() ) ;
}

function test_CheckIsCollapsed()
{
	var range = new FCKDomRange( window ) ;
	range.SetStart( document.getElementById('_P'), 1 ) ;

	assertTrue( 'CheckIsCollapsed', range.CheckIsCollapsed() ) ;
}

function test_Collapse()
{
	var range = new FCKDomRange( window ) ;
	range.SetStart( document.getElementById('_P'), 1 ) ;
	range.SetEnd( document.getElementById('_Span'), 2 ) ;

	assertEquals( 'StartContainer', document.getElementById('_P'), range.StartContainer ) ;
	assertEquals( 'StartBlock', document.getElementById('_P'), range.StartBlock ) ;
	assertEquals( 'StartBlockLimit', document.body, range.StartBlockLimit ) ;

	assertEquals( 'EndContainer', document.getElementById('_Span'), range.EndContainer ) ;
	assertEquals( 'EndBlock', document.getElementById('_P'), range.EndBlock ) ;
	assertEquals( 'EndBlockLimit', document.body, range.EndBlockLimit ) ;
	assertFalse( 'CheckIsCollapsed', range.CheckIsCollapsed() ) ;

	range.Collapse( true ) ;

	assertEquals( 'StartContainer', document.getElementById('_P'), range.StartContainer ) ;
	assertEquals( 'StartBlock', document.getElementById('_P'), range.StartBlock ) ;
	assertEquals( 'StartBlockLimit', document.body, range.StartBlockLimit ) ;

	assertEquals( 'EndContainer', document.getElementById('_P'), range.EndContainer ) ;
	assertEquals( 'EndBlock', document.getElementById('_P'), range.EndBlock ) ;
	assertEquals( 'EndBlockLimit', document.body, range.EndBlockLimit ) ;
	assertTrue( 'CheckIsCollapsed', range.CheckIsCollapsed() ) ;
}

function test_DeleteContents()
{
	var range = new FCKDomRange( window ) ;
	range.SetStart( document.getElementById('_P'), 1 ) ;
	range.SetEnd( document.getElementById('_Strong'), 2 ) ;

	range.DeleteContents() ;

	assertEquals( 'HTML after deletion', '<strong id=_strong></strong> markup. examples of commonly found content are:', GetTestInnerHtml( document.getElementById( '_P' ) ) ) ;

	assertEquals( 'StartContainer', document.getElementById('_P'), range.StartContainer ) ;
	assertEquals( 'StartBlock', document.getElementById('_P'), range.StartBlock ) ;
	assertEquals( 'StartBlockLimit', document.body, range.StartBlockLimit ) ;

	assertEquals( 'EndContainer', document.getElementById('_P'), range.EndContainer ) ;
	assertEquals( 'EndBlock', document.getElementById('_P'), range.EndBlock ) ;
	assertEquals( 'EndBlockLimit', document.body, range.EndBlockLimit ) ;

	assertTrue( 'CheckIsCollapsed', range.CheckIsCollapsed() ) ;
}

function test_ExtractContents()
{
	var range = new FCKDomRange( window ) ;
	range.SetStart( document.getElementById('_P2'), 1 ) ;
	range.SetEnd( document.getElementById('_Em'), 2 ) ;

	var docFrag = range.ExtractContents() ;

	var tmpDiv = document.createElement( 'div' ) ;
	if ( docFrag.AppendTo ) docFrag.AppendTo( tmpDiv ) ; else tmpDiv.appendChild( docFrag ) ;

	assertEquals( 'Extracted HTML', 'in the test we will try to recreate this document using the editor tools. to make sure tables can be inserted <em id=_em>properly</em>', GetTestInnerHtml( tmpDiv ) ) ;
	assertEquals( 'HTML after extraction', '<em id=_em></em> we re-visit banana import statistics from 1998.', GetTestInnerHtml( document.getElementById( '_P2' ) ) ) ;

	assertEquals( 'StartContainer', document.getElementById('_P2'), range.StartContainer ) ;
	assertEquals( 'StartBlock', document.getElementById('_P2'), range.StartBlock ) ;
	assertEquals( 'StartBlockLimit', document.body, range.StartBlockLimit ) ;

	assertEquals( 'EndContainer', document.getElementById('_P2'), range.EndContainer ) ;
	assertEquals( 'EndBlock', document.getElementById('_P2'), range.EndBlock ) ;
	assertEquals( 'EndBlockLimit', document.body, range.EndBlockLimit ) ;

	assertTrue( 'CheckIsCollapsed', range.CheckIsCollapsed() ) ;
}

function test_Clone()
{
	var range = new FCKDomRange( window ) ;
	range.SetStart( document.getElementById('_P2'), 1 ) ;
	range.SetEnd( document.getElementById('_Em'), 2 ) ;

	var clone = range.Clone() ;
	clone.SetStart( document.getElementById('_P'), 1 ) ;
	clone.Collapse( true ) ;

	assertEquals( 'range.StartContainer', document.getElementById('_P2'), range.StartContainer ) ;
	assertEquals( 'range.StartBlock', document.getElementById('_P2'), range.StartBlock ) ;
	assertEquals( 'range.StartBlockLimit', document.body, range.StartBlockLimit ) ;
	assertEquals( 'range.EndContainer', document.getElementById('_Em'), range.EndContainer ) ;
	assertEquals( 'range.EndBlock', document.getElementById('_P2'), range.EndBlock ) ;
	assertEquals( 'range.EndBlockLimit', document.body, range.EndBlockLimit ) ;
	assertFalse( 'range.CheckIsCollapsed', range.CheckIsCollapsed() ) ;

	assertEquals( 'clone.StartContainer', document.getElementById('_P'), clone.StartContainer ) ;
	assertEquals( 'clone.StartBlock', document.getElementById('_P'), clone.StartBlock ) ;
	assertEquals( 'clone.StartBlockLimit', document.body, clone.StartBlockLimit ) ;
	assertEquals( 'clone.EndContainer', document.getElementById('_P'), clone.EndContainer ) ;
	assertEquals( 'clone.EndBlock', document.getElementById('_P'), clone.EndBlock ) ;
	assertEquals( 'clone.EndBlockLimit', document.body, clone.EndBlockLimit ) ;
	assertTrue( 'clone.CheckIsCollapsed', clone.CheckIsCollapsed() ) ;
}

function test_MoveToNodeContents()
{
	var range = new FCKDomRange( window ) ;
	range.MoveToNodeContents( document.getElementById('_Strong') ) ;

	assertEquals( 'StartContainer', document.getElementById('_Strong'), range.StartContainer ) ;
	assertEquals( 'StartBlock', document.getElementById('_P'), range.StartBlock ) ;
	assertEquals( 'StartBlockLimit', document.body, range.StartBlockLimit ) ;
	assertEquals( 'EndContainer', document.getElementById('_Strong'), range.EndContainer ) ;
	assertEquals( 'EndBlock', document.getElementById('_P'), range.EndBlock ) ;
	assertEquals( 'EndBlockLimit', document.body, range.EndBlockLimit ) ;
	assertFalse( 'CheckIsCollapsed', range.CheckIsCollapsed() ) ;
}

function test_MoveToElementStart()
{
	var range = new FCKDomRange( window ) ;
	range.MoveToElementStart( document.getElementById('_Strong') ) ;

	assertEquals( 'StartContainer', document.getElementById('_Strong'), range.StartContainer ) ;
	assertEquals( 'StartBlock', document.getElementById('_P'), range.StartBlock ) ;
	assertEquals( 'StartBlockLimit', document.body, range.StartBlockLimit ) ;
	assertEquals( 'EndContainer', document.getElementById('_Strong'), range.EndContainer ) ;
	assertEquals( 'EndBlock', document.getElementById('_P'), range.EndBlock ) ;
	assertEquals( 'EndBlockLimit', document.body, range.EndBlockLimit ) ;
	assertTrue( 'CheckIsCollapsed', range.CheckIsCollapsed() ) ;
}

function test_InsertNode()
{
	var range = new FCKDomRange( window ) ;
	range.MoveToElementStart( document.getElementById('_Strong') ) ;

	var eNewNode = document.createElement( 'span' ) ;
	eNewNode.innerHTML = 'test' ;
	range.InsertNode( eNewNode ) ;

	assertEquals( 'HTML after insertion', '<span>test</span>proper', GetTestInnerHtml( document.getElementById( '_Strong' ) ) ) ;

	assertEquals( 'StartContainer', document.getElementById('_Strong'), range.StartContainer ) ;
	assertEquals( 'StartBlock', document.getElementById('_P'), range.StartBlock ) ;
	assertEquals( 'StartBlockLimit', document.body, range.StartBlockLimit ) ;
	assertEquals( 'EndContainer', document.getElementById('_Strong'), range.EndContainer ) ;
	assertEquals( 'EndBlock', document.getElementById('_P'), range.EndBlock ) ;
	assertEquals( 'EndBlockLimit', document.body, range.EndBlockLimit ) ;
	assertFalse( 'CheckIsCollapsed', range.CheckIsCollapsed() ) ;
}

function test_CheckIsEmpty_1()
{
	var range = new FCKDomRange( window ) ;
	range.MoveToElementStart( document.getElementById('_Strong') ) ;

	assertTrue( range.CheckIsEmpty() ) ;
}

function test_CheckIsEmpty_2()
{
	var range = new FCKDomRange( window ) ;
	range.MoveToNodeContents( document.getElementById('_Strong') ) ;

	assertFalse( range.CheckIsEmpty() ) ;
}

function test_CheckIsEmpty_3()
{
	var range = new FCKDomRange( window ) ;
	range.MoveToNodeContents( document.getElementById('_Pnbsp') ) ;

	assertFalse( range.CheckIsEmpty() ) ;
}

function test_CheckIsEmpty_4()
{
	var range = new FCKDomRange( window ) ;
	range.MoveToNodeContents( document.getElementById('_Pspaces') ) ;

	assertTrue( range.CheckIsEmpty() ) ;
}

function test_CheckIsEmpty_5()
{
	var range = new FCKDomRange( window ) ;
	range.MoveToNodeContents( document.getElementById('_Strong').firstChild ) ;
	range.SetEnd( document.getElementById('_Strong'), 2 ) ;

	assertFalse( range.CheckIsEmpty() ) ;
}

function test_CheckStartOfBlock_1()
{
	var range = new FCKDomRange( window ) ;
	range.MoveToNodeContents( document.getElementById('_P') ) ;

	assertTrue( range.CheckStartOfBlock() ) ;
}

function test_CheckStartOfBlock_2()
{
	var range = new FCKDomRange( window ) ;
	range.MoveToNodeContents( document.getElementById('_P').firstChild ) ;

	assertTrue( range.CheckStartOfBlock() ) ;
}

function test_CheckStartOfBlock_3()
{
	var range = new FCKDomRange( window ) ;
	range.SetStart( document.getElementById('_Span').nextSibling, 1 ) ;

	assertFalse( range.CheckStartOfBlock() ) ;
}

function test_CheckEndOfBlock_1()
{
	var range = new FCKDomRange( window ) ;
	range.MoveToNodeContents( document.getElementById('_P') ) ;

	assertTrue( range.CheckEndOfBlock() ) ;
}

function test_CheckEndOfBlock_2()
{
	var range = new FCKDomRange( window ) ;
	range.SetStart( document.getElementById('_P'), 2 ) ;

	assertTrue( range.CheckEndOfBlock() ) ;
}

function test_CheckEndOfBlock_3()
{
	var range = new FCKDomRange( window ) ;
	range.SetStart( document.getElementById('_Span').nextSibling, 1 ) ;

	assertFalse( range.CheckEndOfBlock() ) ;
}

function test_MoveToBookmark_1()
{
	var bodyHtml = document.body.innerHTML ;

	var range = new FCKDomRange( window ) ;
	range.SetStart( document.getElementById('_Span'), 1 ) ;
	range.SetEnd( document.getElementById('_P'), 2 ) ;

	assertEquals( '1.StartContainer', document.getElementById('_Span'), range.StartContainer ) ;
	assertEquals( '1.StartBlock', document.getElementById('_P'), range.StartBlock ) ;
	assertEquals( '1.StartBlockLimit', document.body, range.StartBlockLimit ) ;
	assertEquals( '1.EndContainer', document.getElementById('_P'), range.EndContainer ) ;
	assertEquals( '1.EndBlock', document.getElementById('_P'), range.EndBlock ) ;
	assertEquals( '1.EndBlockLimit', document.body, range.EndBlockLimit ) ;
	assertFalse( '1.CheckIsCollapsed', range.CheckIsCollapsed() ) ;

	var bookmark = range.CreateBookmark() ;

	range.MoveToElementStart( document.getElementById('_P2') ) ;

	assertEquals( '2.StartContainer', document.getElementById('_P2'), range.StartContainer ) ;
	assertEquals( '2.StartBlock', document.getElementById('_P2'), range.StartBlock ) ;
	assertEquals( '2.StartBlockLimit', document.body, range.StartBlockLimit ) ;
	assertEquals( '2.EndContainer', document.getElementById('_P2'), range.EndContainer ) ;
	assertEquals( '2.EndBlock', document.getElementById('_P2'), range.EndBlock ) ;
	assertEquals( '2.EndBlockLimit', document.body, range.EndBlockLimit ) ;
	assertTrue( '2.CheckIsCollapsed', range.CheckIsCollapsed() ) ;

	range.MoveToBookmark( bookmark ) ;

	assertEquals( '3.StartContainer', document.getElementById('_Span'), range.StartContainer ) ;
	assertEquals( '3.StartBlock', document.getElementById('_P'), range.StartBlock ) ;
	assertEquals( '3.StartBlockLimit', document.body, range.StartBlockLimit ) ;
	assertEquals( '3.EndContainer', document.getElementById('_P'), range.EndContainer ) ;
	assertEquals( '3.EndBlock', document.getElementById('_P'), range.EndBlock ) ;
	assertEquals( '3.EndBlockLimit', document.body, range.EndBlockLimit ) ;
	assertFalse( '3.CheckIsCollapsed', range.CheckIsCollapsed() ) ;

	// The body HTML must remain unchanged.
	assertEquals( bodyHtml, document.body.innerHTML ) ;
}

function test_MoveToBookmark_2()
{
	var bodyHtml = document.body.innerHTML ;

	var range = new FCKDomRange( window ) ;
	range.SetStart( document.getElementById('_Span'), 1 ) ;

	assertEquals( '1.StartContainer', document.getElementById('_Span'), range.StartContainer ) ;
	assertEquals( '1.StartBlock', document.getElementById('_P'), range.StartBlock ) ;
	assertEquals( '1.StartBlockLimit', document.body, range.StartBlockLimit ) ;
	assertEquals( '1.EndContainer', document.getElementById('_Span'), range.EndContainer ) ;
	assertEquals( '1.EndBlock', document.getElementById('_P'), range.EndBlock ) ;
	assertEquals( '1.EndBlockLimit', document.body, range.EndBlockLimit ) ;
	assertTrue( '1.CheckIsCollapsed', range.CheckIsCollapsed() ) ;

	var bookmark = range.CreateBookmark() ;

	range.MoveToNodeContents( document.getElementById('_P2') ) ;

	assertEquals( '2.StartContainer', document.getElementById('_P2'), range.StartContainer ) ;
	assertEquals( '2.StartBlock', document.getElementById('_P2'), range.StartBlock ) ;
	assertEquals( '2.StartBlockLimit', document.body, range.StartBlockLimit ) ;
	assertEquals( '2.EndContainer', document.getElementById('_P2'), range.EndContainer ) ;
	assertEquals( '2.EndBlock', document.getElementById('_P2'), range.EndBlock ) ;
	assertEquals( '2.EndBlockLimit', document.body, range.EndBlockLimit ) ;
	assertFalse( '2.CheckIsCollapsed', range.CheckIsCollapsed() ) ;

	range.MoveToBookmark( bookmark ) ;

	assertEquals( '3.StartContainer', document.getElementById('_Span'), range.StartContainer ) ;
	assertEquals( '3.StartBlock', document.getElementById('_P'), range.StartBlock ) ;
	assertEquals( '3.StartBlockLimit', document.body, range.StartBlockLimit ) ;
	assertEquals( '3.EndContainer', document.getElementById('_Span'), range.EndContainer ) ;
	assertEquals( '3.EndBlock', document.getElementById('_P'), range.EndBlock ) ;
	assertEquals( '3.EndBlockLimit', document.body, range.EndBlockLimit ) ;
	assertTrue( '3.CheckIsCollapsed', range.CheckIsCollapsed() ) ;

	// The body HTML must remain unchanged.
	assertEquals( bodyHtml, document.body.innerHTML ) ;
}

function test_Expand_1()
{
	var range = new FCKDomRange( window ) ;
	range.SetStart( document.getElementById('_A'), 1 ) ;
	range.SetEnd( document.getElementById('_Img'), 3 ) ;

	range.Expand( 'block_contents' ) ;

	assertEquals( 'StartContainer', document.getElementById('_P'), range.StartContainer ) ;
	assertEquals( 'StartBlock', document.getElementById('_P'), range.StartBlock ) ;
	assertEquals( 'StartBlockLimit', document.body, range.StartBlockLimit ) ;
	assertEquals( 'EndContainer', document.getElementById('_P3'), range.EndContainer ) ;
	assertEquals( 'EndBlock', document.getElementById('_P3'), range.EndBlock ) ;
	assertEquals( 'EndBlockLimit', document.body, range.EndBlockLimit ) ;
	assertFalse( 'CheckIsCollapsed', range.CheckIsCollapsed() ) ;

	assertTrue( 'CheckStartOfBlock', range.CheckStartOfBlock() ) ;
	assertTrue( 'CheckEndOfBlock', range.CheckEndOfBlock() ) ;
}

function test_Expand_2()
{
	var range = new FCKDomRange( window ) ;
	range.MoveToNodeContents( document.getElementById('_StrongNoPara') ) ;

	range.Expand( 'block_contents' ) ;

	assertEquals( 'StartContainer', document.body, range.StartContainer ) ;
	assertNull( 'StartBlock', range.StartBlock ) ;
	assertEquals( 'StartBlockLimit', document.body, range.StartBlockLimit ) ;
	assertEquals( 'EndContainer', document.body, range.EndContainer ) ;
	assertNull( 'EndBlock', range.EndBlock ) ;
	assertEquals( 'EndBlockLimit', document.body, range.EndBlockLimit ) ;
	assertFalse( 'CheckIsCollapsed', range.CheckIsCollapsed() ) ;

	var docFrag = range.ExtractContents() ;

	var tmpDiv = document.createElement( 'div' ) ;
	if ( docFrag.AppendTo ) docFrag.AppendTo( tmpDiv ) ; else tmpDiv.appendChild( docFrag ) ;

	assertEquals( 'Range HTML', 'this text has no block tag.<br>it should be corrected when working with the enter key set to p or div tags. the <strong id=_strongnopara>br configuration</strong> should not make changes instead.<br>it has three lines separated by br tags.', GetTestInnerHtml( tmpDiv ) ) ;
}

function test_Expand_3()
{
	var range = new FCKDomRange( window ) ;
	range.MoveToNodeContents( document.getElementById('_I1') ) ;

	range.Expand( 'inline_elements' ) ;

	var innerRange = range._Range ;

	assertEquals( 'startContainer', document.getElementById('_I1').parentNode, innerRange.startContainer ) ;
	assertEquals( 'startOffset', FCKDomTools.GetIndexOf( document.getElementById('_I1') ), innerRange.startOffset ) ;
	assertEquals( 'endContainer', document.getElementById('_B1').parentNode, innerRange.endContainer ) ;
	assertEquals( 'endOffset', FCKDomTools.GetIndexOf( document.getElementById('_B1') ) + 1, innerRange.endOffset ) ;
}

// #1392
function test_Expand_4()
{
	var textNode = document.getElementById('_B1').childNodes[2] ;

	var range = new FCKDomRange( window ) ;
	range.MoveToNodeContents( textNode ) ;

	range.Expand( 'inline_elements' ) ;

	var innerRange = range._Range ;

	assertEquals( 'startContainer', textNode, innerRange.startContainer ) ;
	assertEquals( 'startOffset', 0, innerRange.startOffset ) ;
	assertEquals( 'endContainer', textNode, innerRange.endContainer ) ;
	assertEquals( 'endOffset', textNode.nodeValue.length, innerRange.endOffset ) ;
}

	</script>
	<script type="text/javascript">

var _BodyHtml ;

function setUpPage()
{
	_BodyHtml = document.body.innerHTML ;
	setUpPageStatus = 'complete' ;
}

// JsUnit special function called before every test start.
function setUp()
{
	// Reset the body (because of changes by test functions).
	document.body.innerHTML = _BodyHtml ;
}

// Use window.onload to call a test outside JsUnit (for debugging).
// The "tests.js" script must be commented.
//window.onload = function()
//{
//	test_CheckIsEmpty_5() ;
//}

	</script>
</head>
<body>
	<h1>
		Test page for FCKeditor
	</h1>
	<p id="_P">
		This document contains various markup features commonly used by content editors
		or "<span id="_Span" lang="fr">r&eacute;dacteurs de contenu</span>" as they are
		called in <a id="_A" href="http://en.wikipedia.org/wiki/France" title="Wikipedia article about France">
			France</a>.<br />
		It is important that a <acronym id="_Acronym" title="what you see is what you get">WYSIWYG</acronym>
		tool has features that are easily available for the editor. If not, there is a risk
		that content won't receive <strong id="_Strong">proper</strong> markup. Examples
		of commonly found content are:</p>
	<p id="_Pnbsp">
		&nbsp;
	</p>
	<p id="_Pspaces">
	</p>
	<ol>
		<li>Headings</li>
		<li style="color: Red">Links (with optional title) </li>
		<li>Lists (like this one)
			<ul>
				<li>including nested lists </li>
			</ul>
		</li>
		<li>Tables
			<ul>
				<li>caption</li>
				<li>headers</li>
				<li>summary</li>
			</ul>
		</li>
		<li>Language information</li>
		<li>Acronyms and abbreviations</li>
		<li>Emphasis and strong emphasis </li>
		<li>Quotes, inline and block </li>
		<li>Images</li>
	</ol>
	<hr />
	<h2 style="background-color: Silver">
		Test procedure
	</h2>
	This text has no block tag. It should be corrected when working with the enter key
	set to "p" or "div" tags. The "br" configuration should not make changes instead.
	<p id="_P2">
		In the test we will try to recreate this document using the editor tools. To make
		sure tables can be inserted <em id="_Em">properly</em> we re-visit banana import
		statistics from 1998.
	</p>
	<p id="_P3">
		This paragraph has and image at the very end of its contents.<img id="_Img" src="img.gif"
			alt="" />
	</p>
	This text has no block tag.<br />It should be corrected when working with the enter key
	set to "p" or "div" tags. The <strong id="_StrongNoPara">"br" configuration</strong>
	should not make changes instead.<br />It has three lines separated by BR tags.
	<p>
		In the test we will try to recreate this document using the editor tools. To make
		sure tables can be inserted <em>properly</em> we re-visit banana import statistics
		from 1998.
	</p>
	<table summary="Sweden was the top importing country by far in 1998.">
		<caption>
			Top banana importers 1998 (value of banana imports in millions of US dollars per
			million people)<br />
			<br />
		</caption>
		<tr>
			<th scope="col">
				Country</th>
			<th scope="col">
				Millions of US dollars per million people</th>
		</tr>
		<tr>
			<td>
				Sweden</td>
			<td>
				17.12</td>
		</tr>
		<tr>
			<td>
				United&nbsp;Kingdom</td>
			<td>
				8.88</td>
		</tr>
		<tr>
			<td>
				Germany</td>
			<td>
				8.36</td>
		</tr>
		<tr>
			<td>
				Italy</td>
			<td>
				5.96</td>
		</tr>
		<tr>
			<td>
				United States</td>
			<td>
				4.78</td>
		</tr>
	</table>
	<p>
		For block quotes we will have a look at <a href="http://fawny.org/rhcp.html">what Joe
			Clark says about redheads</a>:</p>
	<blockquote cite="http://fawny.org/rhcp.html#me">
		<p>
			"Since boyhood I&rsquo;ve always believed, at the deepest level, that redheads are
			standard-bearers of the grandest and most wondrous human beauty."</p>
	</blockquote>
	<p>
		<img src="img.gif" alt="" /></p>
	<p>
		The above is the FCKeditor logo loaded from the FCKeditor.net web site.</p>
	<p><b id="_B1">Line 1<br />Line 2<br /><i id="_I1">Line 3</i></b></p>
</body>
</html>
